<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java File类完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            overflow: hidden;
        }
        .code-header {
            background: #2d2d2d;
            padding: 10px 20px;
            font-size: 14px;
            color: #888;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        pre {
            margin: 0;
            padding: 20px;
            overflow-x: auto;
        }
        .keyword { color: #569cd6; }
        .string { color: #ce9178; }
        .comment { color: #6a9955; }
        .method { color: #dcdcaa; }
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            color: #667eea;
        }
        .table-modern {
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        .table-modern th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-weight: 600;
            padding: 16px;
            text-align: left;
        }
        .table-modern td {
            padding: 16px;
            border-bottom: 1px solid #f0f0f0;
        }
        .table-modern tr:last-child td {
            border-bottom: none;
        }
        .table-modern tr:hover {
            background: #f8f9fa;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-pulse">
                    <i class="fas fa-file-code mr-4"></i>Java File类完全指南
                </h1>
                <p class="text-xl md:text-2xl opacity-90 leading-relaxed">
                    掌握文件操作的艺术，从基础到进阶的完整学习路径
                </p>
                <div class="mt-8 flex justify-center space-x-4">
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-clock mr-2"></i>15分钟阅读
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-code mr-2"></i>6个代码示例
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-chart-line mr-2"></i>从入门到精通
                    </span>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction Card -->
        <div class="max-w-4xl mx-auto mb-12">
            <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">在</span>Java编程世界中，文件操作是每个开发者必须掌握的核心技能。File类作为Java I/O体系的基石，提供了丰富的API来处理文件和目录。本指南将带你深入理解File类的精髓，通过实战代码示例，让你轻松掌握文件操作的各种技巧。
                </p>
            </div>
        </div>

        <!-- Methods Table Section -->
        <section class="max-w-6xl mx-auto mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">
                <i class="fas fa-toolbox mr-3 text-purple-600"></i>File类核心方法速查
            </h2>
            <div class="table-modern">
                <table class="w-full">
                    <thead>
                        <tr>
                            <th class="w-16">序号</th>
                            <th>方法或常量</th>
                            <th class="w-32">类型</th>
                            <th>描述</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="text-center font-semibold text-purple-600">1</td>
                            <td><code class="bg-gray-100 px-2 py-1 rounded text-sm">public static final String pathSeparator</code></td>
                            <td><span class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm">常量</span></td>
                            <td>路径分隔符（Windows: ";"）</td>
                        </tr>
                        <tr>
                            <td class="text-center font-semibold text-purple-600">2</td>
                            <td><code class="bg-gray-100 px-2 py-1 rounded text-sm">public static final String separator</code></td>
                            <td><span class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm">常量</span></td>
                            <td>文件分隔符（Windows: "\"）</td>
                        </tr>
                        <tr>
                            <td class="text-center font-semibold text-purple-600">3</td>
                            <td><code class="bg-gray-100 px-2 py-1 rounded text-sm">public boolean createNewFile() throws IOException</code></td>
                            <td><span class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm">普通方法</span></td>
                            <td><strong>创建新文件</strong></td>
                        </tr>
                        <tr>
                            <td class="text-center font-semibold text-purple-600">4</td>
                            <td><code class="bg-gray-100 px-2 py-1 rounded text-sm">public boolean mkdir()</code></td>
                            <td><span class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm">普通方法</span></td>
                            <td>创建目录</td>
                        </tr>
                        <tr>
                            <td class="text-center font-semibold text-purple-600">5</td>
                            <td><code class="bg-gray-100 px-2 py-1 rounded text-sm">public File[] listFiles()</code></td>
                            <td><span class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm">普通方法</span></td>
                            <td>列出目录内容（含完整路径）</td>
                        </tr>
                        <tr>
                            <td class="text-center font-semibold text-purple-600">6</td>
                            <td><code class="bg-gray-100 px-2 py-1 rounded text-sm">public String[] list()</code></td>
                            <td><span class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm">普通方法</span></td>
                            <td>列出目录内容（仅文件名）</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>

        <!-- Concept Map -->
        <section class="max-w-6xl mx-auto mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">
                <i class="fas fa-project-diagram mr-3 text-purple-600"></i>File类操作概念图
            </h2>
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="mermaid">
                    graph TD
                        A[File类] --> B[文件操作]
                        A --> C[目录操作]
                        A --> D[路径处理]
                        
                        B --> B1[创建文件<br/>createNewFile]
                        B --> B2[读取文件<br/>FileInputStream]
                        B --> B3[写入文件<br/>FileOutputStream]
                        B --> B4[文件拷贝]
                        
                        C --> C1[创建目录<br/>mkdir]
                        C --> C2[列出内容<br/>list/listFiles]
                        C --> C3[递归遍历]
                        
                        D --> D1[路径分隔符<br/>separator]
                        D --> D2[路径连接符<br/>pathSeparator]
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                        style B fill:#48bb78,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#ed8936,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#38b2ac,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </section>

        <!-- Code Examples -->
        <section class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-gray-800 mb-12 text-center">
                <i class="fas fa-code mr-3 text-purple-600"></i>实战代码示例
            </h2>

            <!-- Example 1 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold text-gray-700 mb-4">
                    <i class="fas fa-file-plus mr-2 text-green-500"></i>创建新文件
                </h3>
                <div class="code-block">
                    <div class="code-header">
                        <span><i class="fab fa-java mr-2"></i>Test01.java</span>
                        <span class="text-xs bg-green-600 text-white px-2 py-1 rounded">基础示例</span>
                    </div>
                    <pre><code><span class="keyword">public class</span> <span class="method">Test01</span> {
    <span class="keyword">public static void</span> <span class="method">main</span>(String[] args) {
        File file = <span class="keyword">new</span> File(<span class="string">"F:/file.txt"</span>);
        <span class="keyword">boolean</span> createNewFile;
        <span class="keyword">try</span> {
            createNewFile = file.createNewFile(); <span class="comment">// 创建文本文件</span>
            System.out.println(createNewFile);
        } <span class="keyword">catch</span> (IOException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                </div>
            </div>

            <!-- Example 2 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold text-gray-700 mb-4">
                    <i class="fas fa-list mr-2 text-blue-500"></i>list()与listFiles()的区别
                </h3>
                <div class="code-block">
                    <div class="code-header">
                        <span><i class="fab fa-java mr-2"></i>Test01.java</span>
                        <span class="text-xs bg-blue-600 text-white px-2 py-1 rounded">对比示例</span>
                    </div>
                    <pre><code><span class="keyword">public class</span> <span class="method">Test01</span> {
    <span class="keyword">public static void</span> <span class="method">main</span>(String[] args) {
        File file = <span class="keyword">new</span> File(<span class="string">"F:/"</span>);
        
        String[] list = file.list(); <span class="comment">// 列出名称</span>
        System.out.println(<span class="string">"字符串类型："</span>);
        <span class="keyword">for</span> (String string : list) {
            System.out.println(string);
        }
        
        File[] listFiles = file.listFiles(); <span class="comment">// 列出完整的路径</span>
        System.out.println(<span class="string">"File类型："</span>);
        <span class="keyword">for</span> (File fi : listFiles) {
            System.out.println(fi);
        }
    }
}</code></pre>
                </div>
            </div>

            <!-- Example 3 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold text-gray-700 mb-4